/*
pku1315 Éî¶ÈÓÅÏÈËÑË÷ 
Don't Get Rooked
http://acm.pku.edu.cn/JudgeOnline/problem?id=1315
*/
#include <stdio.h>
#include <string.h>

int pos[4][4];
int n, i, ans, cnt;
char tu[5][5];


bool init() {
    scanf("%d", &n);
    if (n == 0) return false;
    for (i=0; i<n; ++i)
        scanf("%s", tu[i]);
    return true;
}    

bool check(int x, int y) {
    int tox, toy;
    tox = x , toy = y;
    while (tox > 0) {
        tox--;
        if (tu[tox][toy]=='X') break;
        if (pos[tox][toy] == 1) return false;
    }    
    tox = x , toy = y;
    while (toy >0) {
        toy--;
        if (tu[tox][toy]=='X') break;
        if (pos[tox][toy] == 1) return false;
    }    
    return true;
}
    
void di(int x, int y) {
    int tox, toy;
    if (x >= n) {
        if (ans < cnt) ans = cnt;
        return ;
    } else {
        tox = x; 
        toy = y+1;
        if (toy == n) tox++, toy=0;
        pos[x][y] = 0;
        di(tox, toy);
        if (tu[x][y]!='X') {
            pos[x][y] = 1;
            cnt ++;
            if (check(x, y)) 
                di(tox, toy);
            cnt--;
        }    
            
    }         
    
}    

void deal() {
    memset(pos, 0, sizeof(pos));
    ans = cnt = 0;
    di(0, 0);
    printf("%d\n", ans);
}    

int main()
{
    while (init()) {
        deal();
    }    
    return 0;
}    
